(function () {
    'use strict';

    angular
    .module('app')
    .factory('APICouponService', APICouponService);

    APICouponService.$inject = ['$http', '$q', '$timeout', 'CacheFactory', 'ENUM'];

    function APICouponService($http, $q, $timeout, CacheFactory, ENUM) {

        var service = new APIEndpoint( $http, $q, $timeout, CacheFactory, 'APICouponService' );

        service.list = function( params ) {
            return this.fetch( 'ecapi.coupon.list', params, false, function(res){
                return ENUM.ERROR_CODE.OK == res.data.code ? res.data.data : null;
            });
        };

        service.available = function( params ) {
            return this.fetch( 'ecapi.coupon.list', params, false, function(res){
                return ENUM.ERROR_CODE.OK == res.data.code ? res.data.data : null;
            });
        };

        return service;

    }

})();
